const API = require('./base')


export function updateFollow(data){
  return API.post('/wp-json/mp/v2/user', data, {
    token: true
  });
}

export function fav(data){
  return API.post('/wp-json/mp/v2/comments?type=fav', data, {
    token: true
  });
}
export function like(data){
  return API.post('/wp-json/mp/v2/comments?type=like', data, {
    token: true
  });
}

export function getSiteInfo(data) {
  return API.get('/wp-json/mp/v2/setting', data);
}

/**
 * 获取网站轮播图
 * 
 */

export function getBanner(type) {
  return API.get('/wp-json/mp/v2/banner/'+type);
}


export function  getProfile() {
  API.login();
  return API.getProfile();
}

export function getComments(args){
  return API.get('/wp-json/mp/v2/comments', args, {
    token: true,
  })
}

export function getRelateForum(id){
  return API.get('/wp-json/mp/v2/forums?custom=relate&id=' + id);
}

export function markComment(args){
  return API.post('/wp-json/mp/v2/comments/mark', args, {
    token: true,
  })

}

export function uploadMedia(files){
  return API.media(files, {
    token: true
  })
}

export function deletePost(id) {
  return API.delete('/wp-json/mp/v2/posts?post_id=' + id, {}, {
    token: true
  })
}

export function addComments(data){
  return API.post('/wp-json/mp/v2/comments?type=comment', data, {
    token: true
  });
}


/**
 * 分享链接文章
 */
export function getShareLink (data) {
  return API.get('https://mall.guqule.com/mp/share.php', data,{isCusUrl:true});
}



export function getpddSearch  (args) {
  return API.get('/wp-json/mp/v2/pdd/search', args, {
    token: true
  })
}

/**
 * 获取拼多多产品详情
 */

export function getpdddetail(args){
  return API.get('/wp-json/mp/v2/pdd/detail', args, {
    token: true
  })
}

/**
 * 获取拼多多产品链接
 */

export function getpddgenerate  (args) {
  return API.get('/wp-json/mp/v2/pdd/generate', args, {
    token: true
  })
}



export function getCodeImg(data) {
  return API.post('/wp-json/mp/v2/qrcode', data, {
    token: false
  });
}

export function getUserSearch(data) {
  return API.get('/wp-json/mp/v2/user/search', data, {
    token: false
  });
}

export function updataShareCredits(data){
  return API.get('/wp-json/mp/v2/credit/invite', data, {
    token: true
  });
}

export function getRankList(data){
  return API.get('/wp-json/mp/v2/credit/rank?orderby=credits', data, {
    token: true
  });
}